package com.bxd.baodan.util;

import android.util.Log;

/**
 * 1.关闭日志
 * 2.改推送线上
 * 3.改版本号
 * 4.改升级号
 * 5.改数据库
 * 6.线上环境
 */
public class LogUtil {
    //可以全局控制是否打印log日志
    public static boolean isPrintLog = true;

    private static int LOG_MAX_LENGTH = 2000;


    public static void e(String msg) {
        if (isPrintLog) {

            int strLength = msg.length();
            int start = 0;
            int end = LOG_MAX_LENGTH;
            for (int i = 0; i < strLength; i++) {
                if (strLength > end) {
                    Log.e("执行_" + i, msg.substring(start, end));
                    start = end;
                    end = end + LOG_MAX_LENGTH;
                } else {
                    Log.e("执行_" + i, msg.substring(start, strLength) + "\n");
                    break;
                }
            }
        }
    }

    public static void e(String type, String msg) {

        if (isPrintLog) {

            int strLength = msg.length();
            int start = 0;
            int end = LOG_MAX_LENGTH;
            for (int i = 0; i < 100; i++) {
                if (strLength > end) {
                    Log.e(type + "_" + i, msg.substring(start, end));
                    start = end;
                    end = end + LOG_MAX_LENGTH;
                } else {
                    Log.e(type + "_" + i, msg.substring(start, strLength));
                    break;
                }
            }
        }
    }
}